
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Installing More Tools · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-ace/ace.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="styles.css">
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="0.4.html" />
    
    
    <link rel="prev" href="0.2.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="PA0.html">
            
                <a href="PA0.html">
            
                    
                    PA0 - 世界诞生的前夜: 开发环境配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="0.1.html">
            
                <a href="0.1.html">
            
                    
                    Installing a GNU/Linux VM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="0.2.html">
            
                <a href="0.2.html">
            
                    
                    First Exploration with GNU/Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.3" data-path="0.3.html">
            
                <a href="0.3.html">
            
                    
                    Installing More Tools
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="0.4.html">
            
                <a href="0.4.html">
            
                    
                    More Exploration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="0.5.html">
            
                <a href="0.5.html">
            
                    
                    Logging in via SSH
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="0.6.html">
            
                <a href="0.6.html">
            
                    
                    Transferring Files between host and VM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="0.7.html">
            
                <a href="0.7.html">
            
                    
                    Acquiring Source Code for PAs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="PA1.html">
            
                <a href="PA1.html">
            
                    
                    PA1 - 洞察世界的视点: 简易调试器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    在开始愉快的PA之旅之前
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    RTFSC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    简易调试器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" data-path="1.3.1.html">
            
                <a href="1.3.1.html">
            
                    
                    基本功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" data-path="1.3.2.html">
            
                <a href="1.3.2.html">
            
                    
                    表达式求值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.3" data-path="1.3.3.html">
            
                <a href="1.3.3.html">
            
                    
                    监视点
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="1.4.html">
            
                <a href="1.4.html">
            
                    
                    熟悉i386手册
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="PA2.html">
            
                <a href="PA2.html">
            
                    
                    PA2 - 不停计算的机器: 指令系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="2.1.html">
            
                <a href="2.1.html">
            
                    
                    x86指令系统简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="2.2.html">
            
                <a href="2.2.html">
            
                    
                    RTFSC(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.3.html">
            
                <a href="2.3.html">
            
                    
                    运行第一个C程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="2.4.html">
            
                <a href="2.4.html">
            
                    
                    实现更多的指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="2.5.html">
            
                <a href="2.5.html">
            
                    
                    简易调试器(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="2.6.html">
            
                <a href="2.6.html">
            
                    
                    实现加载程序的loader
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="2.7.html">
            
                <a href="2.7.html">
            
                    
                    运行hello-str程序
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="PA3.html">
            
                <a href="PA3.html">
            
                    
                    PA3 - 虚实交错的魔法: 存储管理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    Cache的故事
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    IA-32的故事
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="3.2.1.html">
            
                <a href="3.2.1.html">
            
                    
                    混沌初开
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.2" data-path="3.2.2.html">
            
                <a href="3.2.2.html">
            
                    
                    建立新秩序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.3" data-path="3.2.3.html">
            
                <a href="3.2.3.html">
            
                    
                    迈进新时代
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2.4" data-path="3.2.4.html">
            
                <a href="3.2.4.html">
            
                    
                    从一到无穷大
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="PA4.html">
            
                <a href="PA4.html">
            
                    
                    PA4 - 来自外部的声音: 中断与I/O
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    穿越时空的旅程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    时空之旅大揭秘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    天外有天的世界
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="4.4.html">
            
                <a href="4.4.html">
            
                    
                    加入最后的拼图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="4.5.html">
            
                <a href="4.5.html">
            
                    
                    移植打字小游戏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="4.6.html">
            
                <a href="4.6.html">
            
                    
                    通往高速的次元
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="4.7.html">
            
                <a href="4.7.html">
            
                    
                    移植仙剑奇侠传
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="4.8.html">
            
                <a href="4.8.html">
            
                    
                    编写不朽的传奇
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="blank.html">
            
                <a href="blank.html">
            
                    
                    杂项
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="why.html">
            
                <a href="why.html">
            
                    
                    为什么要学习计算机系统基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="submit.html">
            
                <a href="submit.html">
            
                    
                    实验提交要求
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="linux.html">
            
                <a href="linux.html">
            
                    
                    Linux入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="man.html">
            
                <a href="man.html">
            
                    
                    man入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="git.html">
            
                <a href="git.html">
            
                    
                    git入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="i386-typo.html">
            
                <a href="i386-typo.html">
            
                    
                    i386手册勘误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="name.html">
            
                <a href="name.html">
            
                    
                    学生名单
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.7.1" data-path="PA0-feedback.html">
            
                <a href="PA0-feedback.html">
            
                    
                    PA0提交情况
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7.2" data-path="PA1-feedback.html">
            
                <a href="PA1-feedback.html">
            
                    
                    PA1提交情况
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7.3" data-path="PA2-feedback.html">
            
                <a href="PA2-feedback.html">
            
                    
                    PA2提交情况
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7.4" data-path="PA3-feedback.html">
            
                <a href="PA3-feedback.html">
            
                    
                    PA3提交情况
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="feedback.html">
            
                <a href="feedback.html">
            
                    
                    收集课程感想
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Installing More Tools</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="installing-more-tools">Installing More Tools</h2>
<p>In GNU/Linux, you can download and install a software by one command (which is difficult to do in Windows). This is achieved by the package manager. Different GNU/Linux distribution has different package manager. In Debian, the package manager is called <code>apt</code>.</p>
<h3 id="installing-tools-from-the-debian-image">Installing tools from the Debian image</h3>
<p>Now you are going to install some tools from the Debian image for convinence. First &quot;insert&quot; the Debian image: Click <code>Devices</code> in the menu bar in the VM window, navigate to <code>CD/DVD Devices</code>, click <code>Choose a virtual CD/DVD disk file...</code>, then select the Debian image file. Then add the sources in the image to the APT&apos;s list by the following command:</p>
<pre><code>apt-cdrom add
</code></pre><p>You will see the following prompt:</p>
<pre><code>Please insert a Disc in the drive and press enter
</code></pre><p>Since you have already &quot;inserted the Disc&quot; just now, press the <code>Enter</code> key, and you will see some message is output. Read them, you will find an error labeled with &quot;Permission denied&quot;. Switch to the root account and execute the above command again, you will find that the command is executed without errors. Now you can install the following tools.</p>
<h4 id="sudo">sudo</h4>
<pre><code>apt-get install sudo
</code></pre><p><code>sudo</code> allows you to execute a command as another user (usually root). This means you do not need to switch to the root account to execute a system administration command or modify a file owned by root. But before you can use <code>sudo</code>, you should add your user account to the sudo group:</p>
<pre><code>addgroup jack sudo
</code></pre><p>Replace &quot;jack&quot; above with your username. To let the above command go into effect, you should login the system again. Type</p>
<pre><code>exit
</code></pre><p>to go back to your user account. And <code>exit</code> again to logout, then login again. Now you can use <code>sudo</code>. If you find an operation requires root permission, append <code>sudo</code> before that operation. For example,</p>
<pre><code>username@hostname:~$ sudo poweroff
</code></pre><p>Note that running <code>sudo</code> may require password. This password is your user account password, not the root one.</p>
<p><div class="panel"><div class="box">Why use &quot;sudo&quot; instead of &quot;su&quot;?</div><div class="word-in-panel"><p>You may consider <code>sudo</code> unnecessary, because you can always perform all operations with the root account. But this may take your system at risk. Can you figure out why?</p>
<p>In fact, all operations related to system changing require root permission. If a malicious program obtains root permission, it can do very bad things, such as deleting system files, to destory your system! Therefore, if an operation can be performed without root permission, perform it without root permission.</p>
</div></div></p>
<h4 id="vim">vim</h4>
<pre><code>apt-get install vim
</code></pre><p><code>vim</code> is called <a href="http://os.51cto.com/art/201101/242518.htm" target="_blank">&#x7F16;&#x8F91;&#x5668;&#x4E4B;&#x795E;</a>. You will use <code>vim</code> for coding in all PAs and Labs, as well as editing other files. Maybe some of you prefer to other editors requiring GUI environment (such Visual Studio). However, you can not use them in some situations, especially when you are accessing a physically remote server:</p>
<ul>
<li>the remote server does not have GUI installed, or</li>
<li>the network condition is so bad that you can not use any GUI tools.</li>
</ul>
<p>In these situations, <code>vim</code> is still a good choice. If you prefer to <code>emacs</code>, you can download and install <code>emacs</code> from network mirrors after the APT sources file is configured.</p>
<h4 id="ssh">ssh</h4>
<pre><code>apt-get install openssh-server
</code></pre><p><code>ssh</code> is a tool for remote accessing. Using <code>ssh</code> in the experiment can take some advantage of the host system. For <code>ssh</code> configuration, see the <a href="http://cslab.nju.edu.cn/ics/index.php/Ics:2013/PA0#Logging_in_via_SSH" target="_blank">Logging in via SSH</a> section.</p>
<h3 id="installing-tools-from-the-network-mirrors">Installing tools from the network mirrors</h3>
<p>Since some tools needed for the PAs can not be found in the Debian image, you will download and install them from the network mirrors. The Debian image will not be used any longer, so &quot;eject&quot; the Debian image: Click <code>Devices</code> in the menu bar in the VM window, navigate to <code>CD/DVD Devices</code>, click <code>Remove disk from virtual drive</code>.</p>
<p>Before using the network mirrors, you should check whether the VM can access the Internet.</p>
<h4 id="checking-network-state">Checking network state</h4>
<p>By the default network setting of the VM, the VM will share the same network state with your host. That is, if your host is able to access the Internet, so does the VM. To test whether the VM is able to access the Internet, you can try to ping a host outside the university LAN:</p>
<pre><code>ping www.baidu.com -c 4
</code></pre><p>You should receive reply packets successfully:</p>
<pre><code>PING www.a.shifen.com (220.181.111.188) 56(84) bytes of data.
64 bytes from 220.181.111.188: icmp_seq=1 ttl=51 time=5.81 ms
64 bytes from 220.181.111.188: icmp_seq=2 ttl=51 time=6.11 ms
64 bytes from 220.181.111.188: icmp_seq=3 ttl=51 time=6.88 ms
64 bytes from 220.181.111.188: icmp_seq=4 ttl=51 time=4.92 ms

--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 4.925/5.932/6.882/0.706 ms
</code></pre><p>If you still get an &quot;unreachable&quot; message, please check whether you can access www.baidu.com in the host system, as well as your configuration.</p>
<h4 id="learning-vim">Learning vim</h4>
<p>You are going to be asked to modify a file using <code>vim</code>. For most of you, this is the first time to use <code>vim</code>. The operations in <code>vim</code> are quite different from other editors you have ever used. To learn <code>vim</code>, you need a tutorial. There are two ways to get tutorials:</p>
<ul>
<li>Issue the <code>vimtutor</code> command in terminal. This will launch a tutorial for <code>vim</code>. <font color="red">This way is recommended, since you can read the tutorial and practice at the same time.</font></li>
<li>Search the Internet with keyword &quot;vim &#x6559;&#x7A0B;&quot;, and you will find a lot of tutorials about <code>vim</code>. Choose some of them to read, meanwhile you can practice with the a temporary file by<pre><code>vim test
</code></pre></li>
</ul>
<font color="red">PRACTICE IS VERY IMPORTANT. You can not learn anything by only reading the tutorials.</font>

<p><div class="panel"><div class="box">Some games operated with vim</div><div class="word-in-panel"><p>Here are some games to help you master some basic operations in <code>vim</code>. Have fun!</p>
<ul>
<li><a href="http://vim-adventures.com" target="_blank">Vim Adventures</a></li>
<li><a href="http://www.vimsnake.com" target="_blank">Vim Snake</a></li>
<li><a href="http://www.openvim.com/tutorial.html" target="_blank">Open Vim Tutorials</a></li>
<li><a href="http://www.vimgenius.com" target="_blank">Vim Genius</a></li>
</ul>
</div></div></p>
<p><div class="panel"><div class="box">The power of vim</div><div class="word-in-panel"><p>You may never consider what can be done in such a &quot;BAD&quot; editor. Let&apos;s see two examples.</p>
<p>The first example is to generate the following file:</p>
<pre><code>1
2
3
.....
98
99
100
</code></pre><p>This file contains 100 lines, and each line contains a number. What will you do? In <code>vim</code>, this is a piece of cake. First change <code>vim</code> into normal state (when <code>vim</code> is just opened, it is in normal state), then press the following keys sequentially:</p>
<pre><code>i1&lt;ESC&gt;q1yyp&lt;C-a&gt;q98@1
</code></pre><p>where <code>&lt;ESC&gt;</code> means the ESC key, and <code>&lt;C-a&gt;</code> means &quot;Ctrl + a&quot; here. You only press no more than 15 keys to generate this file. Is it amazing? What about a file with 1000 lines? What you do is just to press one more key:</p>
<pre><code>i1&lt;ESC&gt;q1yyp&lt;C-a&gt;q998@1
</code></pre><p>The magic behind this example is recording and replaying. You initial the file with the first line. Then record the generation of the second. After that, you replay the generation for 998 times to obtain the file.</p>
<p>The second example is to modify a file. Suppose you have such a file:</p>
<pre><code>aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffff
ggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjjjjjj
</code></pre><p>You want to modify it into:</p>
<pre><code>bbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaa
dddddddddddddddddddddddddccccccccccccccccccccccccc
fffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeee
hhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggg
jjjjjjjjjjjjjjjjjjjjjjjjjiiiiiiiiiiiiiiiiiiiiiiiii
</code></pre><p>What will you do? In <code>vim</code>, this is a piece of cake, too. First locate the cursor to first &quot;a&quot; in the first line. And change <code>vim</code> into normal state, then press the following keys sequentially:</p>
<pre><code>&lt;C-v&gt;24l4jd$p
</code></pre><p>where <code>&lt;C-v&gt;</code> means &quot;Ctrl + v&quot; here. What about a file with 100 such lines? What you do is just to press one more key:</p>
<pre><code>&lt;C-v&gt;24l99jd$p
</code></pre><p>Although these two examples are artificial, they display the powerful functionality of <code>vim</code>, comparing with other editors you have used.</p>
</div></div></p>
<h4 id="adding-apt-sources">Adding APT sources</h4>
<p>To use network mirrors, you should configure the source list file. This file lists the sources for <code>apt</code> to obtain software information. The source list file is called <code>sources.list</code>, and it is located under <code>/etc/apt</code> directory. Switch to this directory by <code>cd</code> command:</p>
<pre><code>cd /etc/apt
</code></pre><p>Then open <code>sources.list</code> using <code>vim</code>:</p>
<pre><code>vim sources.list
</code></pre><p>you can see the file content:</p>
<pre><code>#

# deb cdrom:[Debian GNU/Linux 8.0.0 _Jessie_ - Official i386 NETINST Binary-1 20150425-11:41]/ jessie main

#deb cdrom:[Debian GNU/Linux 8.0.0 _Jessie_ - Official i386 NETINST Binary-1 20150425-11:41]/ jessie main

deb cdrom:[Debian GNU/Linux 8.0.0 _Jessie_ - Official i386 NETINST Binary-1 20150425-11:41]/ jessie main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main
</code></pre><p>After you learn some basic operations in <code>vim</code> (such as moving, inserting text, deleting text), you can try to modify the <code>sources.list</code> file as following:</p>
<div class="ace"><div class="aceCode" data-config="{&quot;edit&quot;:false,&quot;lang&quot;:&quot;diff&quot;,&quot;check&quot;:false,&quot;theme&quot;:false}">--- before modification
+++ after modification
@@ -7,4 +7,5 @@
-deb cdrom:[Debian GNU/Linux 8.0.0 _Jessie_ - Official i386 NETINST Binary-1 20150425-11:41]/ jessie main
 deb http://security.debian.org/ jessie/updates main
 deb-src http://security.debian.org/ jessie/updates main

+deb http://mirrors.163.com/debian/ jessie main contrib non-free
+deb http://ftp.cn.debian.org/debian/ jessie main contrib non-free<br></div></div>

<p>  We present the modification with <a href="http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html" target="_blank">GNU diff format</a>. Lines starting with <code>+</code> are to be inserted. Lines starting with <code>-</code> are to be deleted. Other lines are not to be modified. If you do not understand the diff format, please search the Internet for more information.</p>
<p>After you are done, you should save your modification. Type</p>
<pre><code>:w
</code></pre><p>to save the file. However, you receive an error message:</p>
<pre><code>E45: &apos;readonly&apos; option is set (add ! to override)
</code></pre><p>According to the message, the file is read-only, but you may use <code>!</code> to force saving. Type</p>
<pre><code>:w!
</code></pre><p>But you receive another error message this time:</p>
<pre><code>&quot;sources.list&quot; E212: Can&apos;t open file for writing
</code></pre><p>It seems that you do not have the permission to write to this file. Type</p>
<pre><code>:q!
</code></pre><p>to exit <code>vim</code> without saving. Back to shell, type </p>
<pre><code>ls -l
</code></pre><p>to display detail information of the files. You will see a list like</p>
<pre><code>total 20
drwxr-xr-x 2 root root 4096 May  6 22:30 apt.conf.d
drwxr-xr-x 2 root root 4096 Apr 14 01:26 preferences.d
-rw-r--r-- 1 root root  432 May  6 22:30 sources.list
drwxr-xr-x 2 root root 4096 Apr 14 01:26 sources.list.d
drwxr-xr-x 2 root root 4096 May  6 22:30 trusted.gpg.d
</code></pre><p><a href="http://en.wikipedia.org/wiki/File_system_permissions#Notation_of_traditional_Unix_permissions" target="_blank">Here</a> are some explanations of what the first column (for example, <code>drwxr-xr-x</code>) of the list means. For more information about what each column means, please search the Internet.</p>
<p>You can see that the <code>sources.list</code> file is owned by root, and you do not have permission to modify it. Therefore, use <code>sudo</code> to open the file:</p>
<pre><code>sudo vim sources.list
</code></pre><p>Then perform the modification. This time you should save the file successfully.</p>
<p>After saving the modification, you can tell <code>apt</code> to retrieve software information from the sources specified in <code>sources.list</code>:</p>
<pre><code>apt-get update
</code></pre><p>This command requires root permission, too. And it requires Internet accessing. It costs some time for this command to finish. If some errors are reported, please check</p>
<ul>
<li>whether there are any typos in <code>sources.list</code>, and</li>
<li>whether your host is able to access the Internet.</li>
</ul>
<h4 id="installing-tools-for-pas">Installing tools for PAs</h4>
<p>The following tools are necessary for PAs:</p>
<pre><code>apt-get install build-essential    # build-essential packages, include binary utilities, gcc, make, and so on
apt-get install gcc-doc        # GCC document
apt-get install gdb            # GNU debugger
apt-get install git            # reversion control system
apt-get install time        # we use the GNU time program instead of the build-in one in bash
</code></pre><p>The usage of these tools is explained later.</p>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By <a href="https://sashimi-yzh.github.io/" target="_blank">Zihao Yu</a>, &#x91C7;&#x7528;<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E;:  2019-05-03 18:37:10 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="0.2.html" class="navigation navigation-prev " aria-label="Previous page: First Exploration with GNU/Linux">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="0.4.html" class="navigation navigation-next " aria-label="Next page: More Exploration">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Installing More Tools","level":"1.2.3","depth":2,"next":{"title":"More Exploration","level":"1.2.4","depth":2,"path":"0.4.md","ref":"0.4.md","articles":[]},"previous":{"title":"First Exploration with GNU/Linux","level":"1.2.2","depth":2,"path":"0.2.md","ref":"0.2.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"3.x.x","theme":"default","variables":{},"plugins":["localized-footer","page-footer-ex","ace","nestedmd","mdinhtml"],"pluginsConfig":{"ace":{},"page-footer-ex":{"copyright":"By [Zihao Yu](https://sashimi-yzh.github.io/), 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于: "},"mdinhtml":{},"search":{},"localized-footer":{"filename":"FOOTER.md","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"nestedmd":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles.css","pdf":"styles.css"}},"file":{"path":"0.3.md","mtime":"2019-05-03T10:37:10.919Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-03T10:38:47.530Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

